
import java.io.*;


public class CompFichier 
{

	public static int CompareSimple(String inputFile, String compareFile) 
	{
		 File file = new File(inputFile);  
	     File cFile = new File(compareFile);  
	     return  file.compareTo(cFile);  

	}
	
	public static String CompareDiff(String inputFile, String compareFile) 
	{
		 String diff ="";
		 int lineCount = 0;
		try{
		
		    FileInputStream inputFileStr = new FileInputStream(inputFile);
		    FileInputStream compareFileStr = new FileInputStream(compareFile);
		    
		
		    DataInputStream in = new DataInputStream(inputFileStr);
		    DataInputStream in2 = new DataInputStream(compareFileStr);
		    
		    BufferedReader brInput = new BufferedReader(new InputStreamReader(in));
		    BufferedReader brComp = new BufferedReader(new InputStreamReader(in2));
		    String strLineIn, strLineCmp;
		

		    while ((strLineIn = brInput.readLine()) != null && (strLineCmp = brComp.readLine()) != null )   
		    {
		    	lineCount++;
		        //comparaison brute
		    	if(strLineIn.compareTo(strLineCmp) != 0)
		    	{
		    		diff += "L."+lineCount+": "+strLineIn+" <> "+strLineCmp+"\n";
		    		System.out.println ("L."+lineCount+": "+strLineIn+" <> "+strLineCmp+"\n");
		    	}
		      
		    }
		    //Close the input stream
		    in.close();
		    in2.close();
		    }catch (Exception e){//Catch exception if any
		      System.err.println("Error: " + e.getMessage());
		      diff += "Error: " + e.getMessage()+"\n";
		    }
			System.out.println (lineCount + " ligne(s) lue(s)\n");
		    return lineCount + " ligne(s) lue(s)+\n"+diff;
	}
}
